<template>
	<view class="container">
		<scroll-view scroll-y="true" class="scrollbox" @scrolltolower="lower" enable-back-to-top="true"
			@scrolltoupper="upper" lower-threshold="112">
			<view class="merchantList">
				<view class="ArrList">
					<view class="List" v-for="(item,index) in fenecList" :key="index">
						<view class="merchan-data">
							<view class="imgData">
								<img style="max-width: 100rpx;max-height: 100rpx;" src="@/static/refundList.png"
									alt="" />
							</view>
							<view class="text">
								<title style="margin-top: 15rpx;font-size: 25rpx;color: #242f66;">
									交易金额：{{item.txnAmt || ""}}元
								</title>
								<title style="margin-top: 2rpx;font-size: 22rpx;color: #242f66;">
									订单号：{{item.merOrderNo || ""}}
								</title>
								<title style="margin-top: 2rpx;font-size: 22rpx;color: #242f66;">交易类型：
									<text v-if="item.orderType == 'PAY'">消费</text>
									<text v-if="item.orderType == 'REFUND'">退款</text>
								</title>
								<title style="margin-top: 2rpx;font-size: 22rpx;color: #242f66;">支付类型：
									<text v-if="item.payType == '1'">银行卡</text>
									<text v-if="item.payType == '2'">支付宝</text>
									<text v-if="item.payType == '3'">微信</text>
									<text v-if="item.payType == '4'">银联二维码</text>
									<text v-if="item.payType == '5'">数币</text>
									<text v-if="item.payType == '6'">现金</text>
									<text v-if="item.payType == '0'">未知</text>
								</title>
								<title style="margin-top: 2rpx;font-size: 22rpx;color: #242f66;">交易时间：<title
										style="font-size: 18rpx;color: #242f66;">{{item.txnTime || ""}}
									</title>
								</title>
								<title style="margin-top: 2rpx;font-size: 22rpx;color: #242f66;">交易状态：
									<text style="color: #437c43;" v-if="item.status == 'S'">交易成功</text>
									<text style="color: #ff5353;" v-if="item.status == 'E'">交易失败</text>
									<text style="color: #e4cc68;" v-if="item.status == 'T'">处理中</text>
									<text style="color: #ffbf68;" v-if="item.status == 'F'">退款申请</text>
									<text style="color: #626eff;" v-if="item.status == 'C'">已撤销</text>
									<text style="" v-if="item.status == 'N'">未知状态</text>
								</title>
							</view>

							<view class="" style="margin: 80rpx 30rpx 30rpx 30rpx;">
								<view class="button-wrap1">
									<uv-button type="primary" size="small" text="详情" @click="detailsPage"></uv-button>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
		<tabBar></tabBar>
	</view>
</template>

<script>
	import {
		order
	} from "@/network/transaction.js"
	export default {
		computed: {
			dropItem(name) {
				return (name) => {
					const result = {};
					const find = this.result.find(item => item.name === name);
					if (find) {
						result.label = find.label;
						result.value = find.value;
					} else {
						result.label = this[name].label;
						result.value = this[name].value;
					}
					return result;
				}
			},
			// 获取当前下拉筛选项
			currentDropItem() {
				return this[this.activeName];
			}
		},
		data() {
			return {
				query: {
					status: "F"
				},
				params: {
					page: 1,
					pageSize: 10,
				},
				fenecList: [],
				value: Number(new Date()),
				// 表示value等于这些值，就属于默认值
				defaultValue: [0, 'all', '0'],
				// 筛选结果
				result: [],
				activeName: 'order',
				total: 0,
				order: {
					label: '支付状态',
					value: 'all',
					activeIndex: 0,
					color: '#333',
					activeColor: '#2878ff',
					child: [{
							label: '处理中',
							value: 'T'
						}, {
							label: ' 成功',
							value: 'S'
						}, {
							label: '失败',
							value: 'E'
						},
						{
							label: '已撤销',
							value: 'C'
						},
						{
							label: '退款申请',
							value: 'F'
						},
						{
							label: '未知状态',
							value: 'N'
						}
					]
				},
				type: {
					label: '支付类型',
					value: 'all',
					activeIndex: 0,
					color: '#333',
					activeColor: '#2878ff',
					child: [{
							label: '银行卡',
							value: '1'
						}, {
							label: '支付宝',
							value: '2'
						}, {
							label: '微信',
							value: '3'
						}, {
							label: '银联二维码',
							value: '4'
						},
						{
							label: '数币',
							value: '5'
						},
						{
							label: '现金',
							value: '6'
						},
						{
							label: '未知',
							value: '0'
						}
					]
				},

			}
		},
		onLoad(e) {
			// const arr = uni.getStorageSync('listData')
			// console.log(arr)
			this.merchantList()
		},
		methods: {
			onShow1() {
				this.onPullDownRefresh1();
			},
			onPullDownRefresh1() {
				this.params.page = 1;
				this.merchantList()
			},
			onReachBottom1() {
				if (this.params.page * this.params.pageSize < this.total) {
					this.params.page = this.params.page + 1
					this.merchantList()
				}
			},
			merchantList() {
				order(this.params, this.query).then(res => {
					console.log(res)
					const code = res.data.code;
					if (code == "000000") {
						if (this.params.page === 1) {
							this.fenecList = res.data.data.rows
						} else {
							this.fenecList = this.fenecList.concat(res.data.data.rows)
						}
						this.total = res.data.data.total
					} else {
						uni.showToast({
							title: res.data.message
						})
					}
				}).catch(err => {
					// console.log(err)
				})
			},
			changeSearch() {
				this.merchantList()
			},
			upper() {
				this.params.page = 1;
				this.merchantList()
			},
			lower() {
				if (this.params.page * this.params.pageSize < this.total) {
					this.params.page = this.params.page + 1
					this.merchantList()
				}
			},
			detailsPage() {
				wx.navigateTo({
					url: '/pages/refund/refundList/refundDetails'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		// height: 100vh;
		display: flex;
		align-items: center;
		/* justify-content: center; */
		flex-direction: column;
	}

	.content {
		width: 90%;
	}

	.search {
		margin-top: 20rpx;
		height: 110rpx;
	}

	/deep/.uv-search {
		height: 100rpx !important;
		background: #EFEFEF !important;
		border-radius: 11px !important;
		border: 1px solid #031A6E;
	}

	.merchantList {
		background: #f4f4f4;
		width: 100%;
	}

	.merchan {
		margin: 5% 0% 0% 5%;
		font-weight: bold;
		color: #242f66;
	}

	.ArrList {
		display: flex;
		align-items: center;
		/* justify-content: center; */
		flex-direction: column;
	}

	.List {
		background: #fff;
		height: 220rpx;
		width: 90%;
		border-radius: 20rpx;
		margin-top: 2%;
	}

	.merchan-data {
		display: flex;
	}

	.imgData {
		width: 100rpx;
		height: 100rpx;
		border-radius: 20rpx;
		// background-image: url('../../static/index.png');
		background-size: 100% 100%;
		margin: 60rpx 35rpx 60rpx 35rpx;
	}

	.image {
		max-width: 100rpx;
		max-height: 100rpx;
	}

	.text {
		width: 100%;
		display: flex;
		flex-flow: column;
	}

	.merchan-data-1 {
		display: flex;
		justify-content: center;
	}

	/deep/.uv-line {
		width: 90% !important;
	}

	.merchan-data-2 {
		margin-top: 8%;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.scrollbox {
		height: calc(100vh);
	}
</style>